package com.gl.order.controller;

import com.gl.order.commom.ResultBean;
import com.gl.order.entity.dto.ShippingAddressDto;
import com.gl.order.entity.vo.ShippingAddressVo;
import com.gl.order.service.ShippingAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author: zhouFL
 * @Date: 2021/6/24 14:23
 * @ClassName: ShippingAddressController
 */
@Api(tags = "客户地址")
@RestController
@RequestMapping("/shippingAddress")
public class ShippingAddressController {

    private ShippingAddressService shippingAddressService;

    public ShippingAddressController(ShippingAddressService shippingAddressService) {
        this.shippingAddressService = shippingAddressService;
    }

    @PostMapping("/addShippingAddress")
    @ApiOperation("添加用户地址")
    public ResultBean<List<ShippingAddressVo>> addShippingAddress(@RequestBody @Valid ShippingAddressDto dto){
        shippingAddressService.addShippingAddress(dto);
        return ResultBean.success(shippingAddressService.findByCustomerId(dto.getCustomerId()));
    }

}
